package com.control;

import com.dbutil.UtilJdbc;
import com.entity.User;
import com.entity.Works;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DoWorkServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        String answer = req.getParameter("answer");
        String date = req.getParameter("date");
        HttpSession session = req.getSession();
        User user= (User) session.getAttribute("user");
        //获取登录对象信息
        Integer id = user.getId();
        String name = user.getUser_name().toString();



        UtilJdbc utilJdbc = new UtilJdbc();
        Boolean flag=utilJdbc.inserWorks(id,name,date,answer);
        if(flag){
                resp.sendRedirect("view_works.jsp?session=yes");
            }
        }


    }

